import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 手动提取的数据 (x, y, P)
data_points = [
    (10, 10, 85.00), (10, 20, 75.00), (10, 30, 68.00), (10, 40, 66.00), (10, 50, 64.00), (10, 60, 61.00),
    (20, 10, 66.00), (20, 20, 48.00), (20, 30, 47.00), (20, 40, 44.00), (20, 50, 46.00), (20, 60, 43.00),
    (30, 10, 46.00), (30, 20, 43.00), (30, 30, 32.00), (30, 40, 28.00), (30, 50, 32.00), (30, 60, 23.00),
    (40, 10, 37.00), (40, 20, 23.00), (40, 30, 27.00), (40, 40, 28.00), (40, 50, 22.00), (40, 60, 17.00),
    (50, 10, 24.00), (50, 20, 22.00), (50, 30, 21.00), (50, 40, 19.00), (50, 50, 14.00), (50, 60, 12.00),
    (60, 10, 16.00), (60, 20, 18.00), (60, 30, 16.00), (60, 40, 13.00), (60, 50, 13.00), (60, 60, 8.00),
    (70, 10, 14.00), (70, 20, 9.00), (70, 30, 7.00), (70, 40, 8.00), (70, 50, 15.00), (70, 60, 15.00),
    (80, 10, 5.00), (80, 20, 13.00), (80, 30, 10.00), (80, 40, 8.00), (80, 50, 7.00), (80, 60, 7.00),
    (90, 10, 12.00), (90, 20, 12.00), (90, 30, 8.00), (90, 40, 12.00), (90, 50, 8.00), (90, 60, 10.00),
    (100, 10, 11.00), (100, 20, 8.00), (100, 30, 14.00), (100, 40, 5.00), (100, 50, 6.00), (100, 60, 7.00)
]

# 分离数据
x = [point[0] for point in data_points]
y = [point[1] for point in data_points]
p = [point[2] for point in data_points]

# 创建3D图形
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111, projection='3d')

# 绘制散点图，根据P值着色
scatter = ax.scatter(x, y, p, c=p, cmap='viridis', s=50, alpha=0.8)

# 添加颜色条
cbar = fig.colorbar(scatter, ax=ax, pad=0.1)
cbar.set_label('P Value (%)', fontsize=12)

# 设置坐标轴标签和标题
ax.set_xlabel('X Value', fontsize=12, labelpad=10)
ax.set_ylabel('Y Value', fontsize=12, labelpad=10)
ax.set_zlabel('P Value (%)', fontsize=12, labelpad=10)
ax.set_title('3D Visualization of X, Y and P Values', fontsize=14, pad=20)

# 调整视角以获得更好的视角
ax.view_init(elev=25, azim=45)

# 调整布局
plt.tight_layout()

plt.savefig('Probability.png')

# 显示图形
plt.show()